import request from "axios"
import { Options } from "../interface"
import { globalConfig } from "../config"
/**单文件上传 */
export function uploadFile<RD = any>(options: Options) {
    const { data, onUploadProgress, requestConfig } = options
    const _request = globalConfig.axios || request
    const _options = {
        url: globalConfig.url || requestConfig?.url,
        method: globalConfig.method || requestConfig?.method,
        headers: globalConfig.headers || requestConfig?.headers,
        timeout: globalConfig.timeout || requestConfig?.timeout,
        onUploadProgress,
        data,
    }
    return _request<{
        data: RD
    }>(_options)
}